package com.yowasa.xiuxian.engine.battle.enemy.strategy;

import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name = "地脉移涌")
@Order(100)
@Component
public class DiMaiYiYong extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int needHp = first.getBattleInfo().getHp() - first.getBattleInfo().getChp();
        int can = (int) (first.getBattleInfo().getHp() * 0.3);

        first.getBattleInfo().setChp(first.getBattleInfo().getChp() + Math.min(needHp,can));

        first.getBattleInfo().setDef((int) (first.getBattleInfo().getDef() + first.getUserBO().getUserOriginBattle().getDef() * 0.2));

        content.getMsgLog().add(first.getUserBO().getName() + "因地脉移涌回复" + can + "点血量,并提升了自己的物抗");
        first.getCd().put("地脉移涌", 5);
    }

    @Override
    public void limit(UserBO user) {}

    @Override
    public String limitDesc() {
        return "无";
    }

    @Override
    public String desc() {
        return "遗迹巨蛇遁入地下，吸收黑泥的能量，提升20%物抗并回复30%血量，cd5回合，战斗5回合后可释放";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        if(content.getTurn() < 5){
            return false;
        }
        Integer cd = user.getCd().get("地脉移涌");
        if (cd != null && cd > 0) {
            return false;
        }
        return true;
    }


}
